#include<bits/stdc++.h>
using namespace std;
#define int long long

const int maxn = 1e5;
const int MOD = 1e9 + 7;

int f[maxn + 5];

void fact() {
	f[1] = 1;
	for (int i = 2; i <= maxn; i++) {
		f[i] = f[i - 1] % MOD * i;
	}
}


signed main() {
//	system("start https://www.lanqiao.cn/problems/4180/learning/");

	int n, x;
	cin >> n;

	fact();

	int sum = 0;
	while (n--) {
		cin >> x;
		sum = sum % MOD + f[x];
	}
	cout << sum % MOD;

	return 0;
}
